package net.togogo.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class JsonController {

    @ResponseBody
    @RequestMapping("/json")
    public User getJson(){
        User user = new User();
        user.setId(1);
        user.setName("钱多多");
        user.setRole("乞丐");
        return user;
    }

    @ResponseBody
    @RequestMapping("/jsonlist")
    public List<User> getJsonlist(){
        List<User> users = new ArrayList<>();
        User user = new User();
        user.setId(1);
        user.setName("钱多多");
        user.setRole("乞丐");
        users.add(user);

        user = new User();
        user.setId(2);
        user.setName("钱多多");
        user.setRole("乞丐");
        users.add(user);

        user = new User();
        user.setId(2);
        user.setName("钱多多");
        user.setRole("乞丐");
        users.add(user);
        return users;
    }
}
